package com.flong.spring.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @Author:liangjl
 * @Date: 2020/6/12-21:44
 * @Eamil:jilongliang@sina.com
 * @Description:
 */
@Aspect
public class LogAspects {


    @Pointcut("execution(public int com.flong.spring.aop.MathCalculator.*(..)) ")
    public void pointCut() {
    }

    @Before("pointCut()")
    public void logStart(JoinPoint joinPoint) {
        Object[] args = joinPoint.getArgs();

        System.out.println("logStart" + joinPoint.getSignature().getName() + "在logStart运行");
    }

    @After("pointCut()")
    public void logEnd(JoinPoint joinPoint) {
        System.out.println("logEnd" + joinPoint.getSignature().getName() + "在logEnd运行");
    }

    @AfterReturning(value = "pointCut()" ,returning = "result")
    public void logRet(JoinPoint joinPoint,Object result) {
        System.out.println("logRet" + joinPoint.getSignature().getName() + "在logRet运行");
    }

    @AfterThrowing(value = "pointCut()", throwing = "exception")
    public void logExce(JoinPoint joinPoint,Exception exception) {
        System.out.println("logExce"+"异常信息："+ exception);
    }
}
